#ifndef ggt_impl_h
#define ggt_impl_h 1

#include "ggt.h"
#include "chef.h"
#include <CORBA.h>
#include <coss/CosNaming.h>
#include <time.h>
#include <string.h>
#include <sstream>
#include <fstream>
#include <iostream>
#include <unistd.h>


using namespace chef;
using namespace ggt;
using namespace std;

class ggt_impl : virtual public POA_ggt::unit
{
private:
	ggt::unit_var rightNeighbor;
	ggt::unit_var leftNeighbor;
	//chef::koordinator *bigBoss;
	chef::koordinator_var bigBoss;
	CORBA::Object_var nsobj;
	CosNaming::NamingContext_var nc;
	CosNaming::Name name;
	CORBA::Object_var obj;

	long myPIDisMyName;
	int sleepingtime;

	bool bereit;
	bool rechnen;
	long mi;
	time_t lifeTime;
	bool initiatedQuery;
	bool kill;
	bool gotResponseWithOne;

	int processTimeout;

	char formattime[8];
	time_t sysZeit;

	ofstream logger;

public:
	//ggt_impl ();
	ggt_impl (int argc, char *argv[], CORBA::Object_var nso,int sleep, int pid, int timeout);

	~ggt_impl();
	/* initial */
	virtual void helloChef();
	virtual long setneighbors(long pidleft,long pidright);
	virtual void setpm(long pm);
	/* rechnen */
	virtual void sendy(long y);
	virtual void query(long pid);
	virtual void response(long y);
	virtual void gotContact();
	/* beenden */
	virtual void close( );
	virtual long getTime();
	virtual bool tryToKill();


};

#endif

